<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <style>
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    .shadow_modal {
      position: fixed;
      top: 0;
      width: 100%;
      height: 100vh;
      background: rgba(0, 0, 0, 0.5);
      visibility: hidden;
    }

    .shadow_modal_active {
      visibility: visible;
      transition: 2s;
    }

    .sidenav {
      height: 100%;
      width: 0;
      position: fixed;
      z-index: 1;
      top: 0;
      left: 0;
      background-color: #111;
      overflow-x: hidden;
      transition: 0.5s;
      padding-top: 60px;
      text-align: center;
    }

    .sidenav a {
      padding: 8px 8px 8px 32px;
      text-decoration: none;
      font-size: 25px;
      color: #818181;
      display: block;
      transition: 0.3s;
    }

    .sidenav a:hover {
      color: #f1f1f1;
    }

    .sidenav .closebtn {
      position: absolute;
      top: 0;
      right: 25px;
      font-size: 36px;
      margin-left: 50px;
    }

    @media screen and (max-height: 450px) {
      .sidenav {
        padding-top: 15px;
      }

      .sidenav a {
        font-size: 18px;
      }
    }
  </style>
</head>

<body>


  <div class="shadow_modal"></div>

  <div id="mySidenav" class="sidenav">
    <a href="javascript:void(0)" class="closebtn" onclick="closeNav()">&times;</a>
    <a href="#">About</a>
    <a href="#">Services</a>
    <a href="#">Clients</a>
    <a href="#">Contact</a>
  </div>


  <h2 id="qweqwe" class="  nnn ">Animated Sidenav Example</h2>
  <p>Click on the element below to open the side navigation menu.</p>
  <span style="font-size:123px;cursor:pointer" onclick="openNav()">&#9776; open</span>


  <h1>动画特效不支持 ie </h1>
  <h1> safari 有 bug </h1>


  <xmp style="font-size: 22px; font-weight: bolder;  margin-bottom: 66px;  color: black;  font-family: '微软雅黑';">


    必知必会

    <span style="font-size:123px;cursor:pointer" onclick="openNav()">&#9776; open</span>


    ~ ios safari 不支持这种写法 ~
    window.addEventListener("click", function(eee) {
       let modalbox = document.getElementsByClassName("shadow_modal")[0];
        if(eee.target == modalbox ){
           closeNav()
        }
    })


    支持 safari 浏览器:
    function openNav() {
      document.getElementById("mySidenav").style.width = "50%";
      document.getElementsByClassName("shadow_modal")[0].classList.add("shadow_modal_active");
    }
  
    function closeNav() {
      document.getElementById("mySidenav").style.width = "0";
      document.getElementsByClassName("shadow_modal")[0].classList.remove("shadow_modal_active");
    }
  
    document.getElementsByClassName("shadow_modal")[0].onclick = function (eee) {
      closeNav()
    }
  </xmp>



  <h1 style="font-size: 161px;">&#9776;</h1>
  <h1 style="font-size: 161px;">&Tilde; ~ <h1>
      <h1 style="font-size: 161px;">&times; <h1>
          <h1 style="font-size: 161px;">&#9855;<h1>

</body>
<script>


  function openNav() {
    document.getElementById("mySidenav").style.width = "50%";
    document.getElementsByClassName("shadow_modal")[0].classList.add("shadow_modal_active");
  }

  function closeNav() {
    document.getElementById("mySidenav").style.width = "0";
    document.getElementsByClassName("shadow_modal")[0].classList.remove("shadow_modal_active");
  }

  document.getElementsByClassName("shadow_modal")[0].onclick = function (eee) {
    closeNav()
  }



</script>

</html>